package net.kelissa.divizor.util;

import org.apache.commons.math.stat.descriptive.DescriptiveStatistics;

/**
*
* @author tazzo
*
*/
public class InnerVectorStatistics
{

 private int n;

 private DescriptiveStatistics[] stats;

 public InnerVectorStatistics(int n)
 {
   this.n = n;
   this.stats = new DescriptiveStatistics[n];
   for (int i = 0; i < n; i++)
   {
     this.stats[i] = new DescriptiveStatistics();
   }

 }

 public double[] getStdDev()
 {
   double[] res = new double[this.n];
   for (int i = 0; i < n; i++)
   {
     double stdDev = this.stats[i].getStandardDeviation();
     res[i]= stdDev;;
   }
   return res;
 }

 public double[] getMean()
 {
   double[] res = new double[this.n];
   for (int i = 0; i < n; i++)
   {
     res[i] = this.stats[i].getMean();
   }

   return res;
 }

 public void add(double[] v)
 {
   for (int i = 0; i < this.n; i++)
   {
     this.stats[i].addValue(v[i]);
   }
 }
}